#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
typedef char BTDataType;
typedef struct BinaryTreeNode {
    BTDataType data;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
}BTNode;
BTNode* BTreeCreat(char* str, int* pi) {
    if ((str[(*pi)]) == '#') {
        (*pi)++;
        return NULL;
    }
    BTNode* root1 = (BTNode*)malloc(sizeof(BTNode));
    if (root1 == NULL)
    {
        perror("cuol:");
        exit(0);
    }
    root1->data = str[((*pi)++)];
    root1->left = BTreeCreat(str, pi);
    root1->right = BTreeCreat(str, pi);
    return root1;
}
void InOrder(BTNode* root) {
    if (root == NULL) {
        return;
    }
    InOrder(root->left);
    printf("%c ", root->data);
    InOrder(root->right);
}
int main() {
    char str[100];
    scanf("%s", str);
    int i = 0;
    BTNode* root = BTreeCreat(str, &i);
    InOrder(root);
    return 0;
}